<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>利用Python实现Android替换内容批量打包 - smartzheng</title>
  <meta name="renderer" content="webkit" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>

<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<meta name="theme-color" content="#f8f5ec" />
<meta name="msapplication-navbutton-color" content="#f8f5ec">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#f8f5ec">


<meta name="author" content="smartzheng" /><meta name="description" content="工作中有一个定制需求：根据不同的用户需求，需要替换APP内的图片，以及部分代码里面的配置信息，打出不同的apk交给客户使用。如果只用生成少量" /><meta name="keywords" content="Hugo, theme, even" />






<meta name="generator" content="Hugo 0.68.3 with theme even" />


<link rel="canonical" href="https://smartzheng.github.io/post/%E5%88%A9%E7%94%A8python%E5%AE%9E%E7%8E%B0android%E6%9B%BF%E6%8D%A2%E5%86%85%E5%AE%B9%E6%89%B9%E9%87%8F%E6%89%93%E5%8C%85/" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">


<link href="/dist/even.c2a46f00.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.css" integrity="sha256-7TyXnr2YU040zfSP+rEcz29ggW4j56/ujTPwjMzyqFY=" crossorigin="anonymous">


<meta property="og:title" content="利用Python实现Android替换内容批量打包" />
<meta property="og:description" content="工作中有一个定制需求：根据不同的用户需求，需要替换APP内的图片，以及部分代码里面的配置信息，打出不同的apk交给客户使用。如果只用生成少量" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://smartzheng.github.io/post/%E5%88%A9%E7%94%A8python%E5%AE%9E%E7%8E%B0android%E6%9B%BF%E6%8D%A2%E5%86%85%E5%AE%B9%E6%89%B9%E9%87%8F%E6%89%93%E5%8C%85/" />
<meta property="article:published_time" content="2018-03-28T00:00:00+00:00" />
<meta property="article:modified_time" content="2018-03-28T00:00:00+00:00" />
<meta itemprop="name" content="利用Python实现Android替换内容批量打包">
<meta itemprop="description" content="工作中有一个定制需求：根据不同的用户需求，需要替换APP内的图片，以及部分代码里面的配置信息，打出不同的apk交给客户使用。如果只用生成少量">
<meta itemprop="datePublished" content="2018-03-28T00:00:00&#43;00:00" />
<meta itemprop="dateModified" content="2018-03-28T00:00:00&#43;00:00" />
<meta itemprop="wordCount" content="1186">



<meta itemprop="keywords" content="" /><meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="利用Python实现Android替换内容批量打包"/>
<meta name="twitter:description" content="工作中有一个定制需求：根据不同的用户需求，需要替换APP内的图片，以及部分代码里面的配置信息，打出不同的apk交给客户使用。如果只用生成少量"/>

<!--[if lte IE 9]>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/classlist/1.1.20170427/classList.min.js"></script>
<![endif]-->

<!--[if lt IE 9]>
  <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]-->

</head>
<body>
  <div id="mobile-navbar" class="mobile-navbar">
  <div class="mobile-header-logo">
    <a href="/" class="logo">smartzheng</a>
  </div>
  <div class="mobile-navbar-icon">
    <span></span>
    <span></span>
    <span></span>
  </div>
</div>
<nav id="mobile-menu" class="mobile-menu slideout-menu">
  <ul class="mobile-menu-list">
    <a href="/">
        <li class="mobile-menu-item">Home</li>
      </a><a href="/post/">
        <li class="mobile-menu-item">Archives</li>
      </a><a href="/tags/">
        <li class="mobile-menu-item">Tags</li>
      </a><a href="/categories/">
        <li class="mobile-menu-item">Categories</li>
      </a>
  </ul>
</nav>
  <div class="container" id="mobile-panel">
    <header id="header" class="header">
        <div class="logo-wrapper">
  <a href="/" class="logo">smartzheng</a>
</div>

<nav class="site-navbar">
  <ul id="menu" class="menu">
    <li class="menu-item">
        <a class="menu-item-link" href="/">Home</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/post/">Archives</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/tags/">Tags</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/categories/">Categories</a>
      </li>
  </ul>
</nav>
    </header>

    <main id="main" class="main">
      <div class="content-wrapper">
        <div id="content" class="content">
          <article class="post">
    
    <header class="post-header">
      <h1 class="post-title">利用Python实现Android替换内容批量打包</h1>

      <div class="post-meta">
        <span class="post-time"> 2018-03-28 </span>
        <div class="post-category">
            <a href="/categories/python/"> Python </a>
            </div>
        
      </div>
    </header>

    <div class="post-toc" id="post-toc">
  <h2 class="post-toc-title">文章目录</h2>
  <div class="post-toc-content always-active">
    <nav id="TableOfContents">
  <ul>
    <li>
      <ul>
        <li><a href="#安装python环境内容不再赘述可参见网上教程我使用的是python3">安装Python环境内容不再赘述，可参见网上教程。我使用的是Python3。</a></li>
        <li><a href="#以下是详细代码可参见注释进行配置">以下是详细代码，可参见注释进行配置。</a></li>
        <li><a href="#代码保存为autoreleasepy">代码保存为autoRelease.py</a></li>
        <li><a href="#默认情况下gradle文件需要加入以下内容">默认情况下，.gradle文件需要加入以下内容：</a></li>
        <li><a href="#android节点下">android节点下：</a></li>
        <li><a href="#输出路径修改">输出路径修改</a></li>
        <li><a href="#默认的applicationid">默认的applicationId</a></li>
        <li><a href="#以上">以上。</a></li>
      </ul>
    </li>
  </ul>
</nav>
  </div>
</div>
    <div class="post-content">
      <blockquote>
<p>工作中有一个定制需求：根据不同的用户需求，需要替换APP内的图片，以及部分代码里面的配置信息，打出不同的apk交给客户使用。如果只用生成少量的apk，那么可以将所有图片放入资源文件夹然后根据服务端的信息来进行指定显示，但是随着客户量增加，需要打出数十个apk，并且启动图片不能根据配置来进行替换。所以必须手动更换图片和代码进行打包。这样容易出错，也比较低效，一旦出错必须全部重新返工。所有就写了一个简单的Python脚本来进行一次性批量打包。
GitHub项目地址:https://github.com/smartzheng/AutoApkRelease</p>
</blockquote>
<h3 id="安装python环境内容不再赘述可参见网上教程我使用的是python3">安装Python环境内容不再赘述，可参见网上教程。我使用的是Python3。</h3>
<h3 id="以下是详细代码可参见注释进行配置">以下是详细代码，可参见注释进行配置。</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span><span class="lnt">14
</span><span class="lnt">15
</span><span class="lnt">16
</span><span class="lnt">17
</span><span class="lnt">18
</span><span class="lnt">19
</span><span class="lnt">20
</span><span class="lnt">21
</span><span class="lnt">22
</span><span class="lnt">23
</span><span class="lnt">24
</span><span class="lnt">25
</span><span class="lnt">26
</span><span class="lnt">27
</span><span class="lnt">28
</span><span class="lnt">29
</span><span class="lnt">30
</span><span class="lnt">31
</span><span class="lnt">32
</span><span class="lnt">33
</span><span class="lnt">34
</span><span class="lnt">35
</span><span class="lnt">36
</span><span class="lnt">37
</span><span class="lnt">38
</span><span class="lnt">39
</span><span class="lnt">40
</span><span class="lnt">41
</span><span class="lnt">42
</span><span class="lnt">43
</span><span class="lnt">44
</span><span class="lnt">45
</span><span class="lnt">46
</span><span class="lnt">47
</span><span class="lnt">48
</span><span class="lnt">49
</span><span class="lnt">50
</span><span class="lnt">51
</span><span class="lnt">52
</span><span class="lnt">53
</span><span class="lnt">54
</span><span class="lnt">55
</span><span class="lnt">56
</span><span class="lnt">57
</span><span class="lnt">58
</span><span class="lnt">59
</span><span class="lnt">60
</span><span class="lnt">61
</span><span class="lnt">62
</span><span class="lnt">63
</span><span class="lnt">64
</span><span class="lnt">65
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="ch">#! python3</span>
<span class="c1"># 替换代码和文件，所替换的文本内容必须是当前文件的唯一字符串（可以加长需要替换扥字符串实现唯一性）</span>
<span class="c1">#如需增加要替换的代码内容或者资源，只需要增加数组并且调用替换方法即可</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="c1">#app启动名</span>
<span class="n">appNames</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&#34;app1&#34;</span><span class="p">,</span><span class="s2">&#34;app2&#34;</span><span class="p">,</span><span class="s2">&#34;app3&#34;</span><span class="p">]</span>
<span class="c1">#gradle中的applicationId</span>
<span class="n">replaceText</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&#34;text1&#34;</span><span class="p">,</span><span class="s2">&#34;text2&#34;</span><span class="p">,</span><span class="s2">&#34;text3&#34;</span><span class="p">]</span>
<span class="c1">#gradle中的applicationId</span>
<span class="n">appIds</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&#34;applicationId1&#34;</span><span class="p">,</span><span class="s2">&#34;applicationId2&#34;</span><span class="p">,</span><span class="s2">&#34;applicationId3&#34;</span><span class="p">]</span>
<span class="c1">#输出apk的文件名</span>
<span class="n">apkNames</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&#34;apk1&#34;</span><span class="p">,</span><span class="s2">&#34;apk2&#34;</span><span class="p">,</span><span class="s2">&#34;apk3&#34;</span><span class="p">]</span>
<span class="c1">#项目的资源文件夹路径</span>
<span class="n">targetDir</span> <span class="o">=</span> <span class="s2">&#34;/Users/smartzheng/AndroidStudioProjects/MyApplication/app/src/main/res&#34;</span>
<span class="c1">#配置自己存放不同apk资源图片的路径,分别命名为apk1，apk2，apk3...（apkNames的每个元素）需要替换的图片必须名字对应一致</span>
<span class="n">sourceDir</span> <span class="o">=</span> <span class="s2">&#34;/Users/smartzheng/custom_app_imgs/&#34;</span>

<span class="c1"># 拷贝替换文件，传入图片路径和项目资源目录</span>
<span class="k">def</span> <span class="nf">copyFiles</span><span class="p">(</span><span class="n">sourceDir</span><span class="p">,</span> <span class="n">targetDir</span><span class="p">):</span>
    <span class="k">for</span> <span class="nb">file</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">sourceDir</span><span class="p">):</span>
        <span class="n">sourceFile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sourceDir</span><span class="p">,</span> <span class="nb">file</span><span class="p">)</span>
        <span class="n">targetFile</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">targetDir</span><span class="p">,</span> <span class="nb">file</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">sourceFile</span><span class="p">):</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">targetDir</span><span class="p">):</span>
                <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">targetDir</span><span class="p">)</span>
            <span class="nb">open</span><span class="p">(</span><span class="n">targetFile</span><span class="p">,</span> <span class="s2">&#34;wb&#34;</span><span class="p">)</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="nb">open</span><span class="p">(</span><span class="n">sourceFile</span><span class="p">,</span> <span class="s2">&#34;rb&#34;</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
        <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">sourceFile</span><span class="p">):</span>
            <span class="n">copyFiles</span><span class="p">(</span><span class="n">sourceFile</span><span class="p">,</span> <span class="n">targetFile</span><span class="p">)</span>

<span class="c1">#替换文本内容，传入文件路径，原字符串，目标字符串</span>
<span class="k">def</span> <span class="nf">replaceText</span><span class="p">(</span><span class="n">f_path</span><span class="p">,</span> <span class="n">text1</span><span class="p">,</span> <span class="n">text2</span><span class="p">):</span>
    <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">f_path</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">r</span><span class="p">:</span>
        <span class="n">s</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
        <span class="n">replace</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">text1</span><span class="p">,</span> <span class="n">text2</span><span class="p">)</span>
    <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">f_path</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">,</span> <span class="n">encoding</span><span class="o">=</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">w</span><span class="p">:</span>
        <span class="n">w</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">replace</span><span class="p">)</span>
    <span class="n">r</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
    <span class="n">w</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>


<span class="k">print</span><span class="p">(</span><span class="s2">&#34;begin&#34;</span><span class="p">)</span>
<span class="c1"># 循环执行打包操作</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">appNames</span><span class="p">)):</span>
    <span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
        <span class="c1"># 替换Config配置文件下的代码内容</span>
        <span class="n">replaceText</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;/Users/smartzheng/AndroidStudioProjects/MyApplication/app/src/main/java/com/smartzheng/Config.java&#39;</span><span class="p">,</span><span class="n">replaceText</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span><span class="n">replaceText</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
        <span class="c1">#替换app名字</span>
        <span class="n">replaceText</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;/Users/smartzheng/AndroidStudioProjects/MyApplication/app/src/main/res/values/strings.xml&#39;</span><span class="p">,</span> <span class="n">appNames</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span><span class="n">appNames</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
        <span class="c1">#替換applicationId,即替换包名</span>
        <span class="n">replaceText</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;/Users/smartzheng/AndroidStudioProjects/MyApplication/app/build.gradle&#39;</span><span class="p">,</span><span class="n">appIds</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span><span class="n">appIds</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
        <span class="c1">#替换输出的路径</span>
        <span class="n">replaceText</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;/Users/smartzheng/AndroidStudioProjects/MyApplication/app/build.gradle&#39;</span><span class="p">,</span><span class="n">apkNames</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span><span class="n">apkNames</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
        <span class="c1"># 替换资源图片</span>
        <span class="n">copyFiles</span><span class="p">(</span><span class="n">sourceDir</span> <span class="o">+</span> <span class="n">apkNames</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">targetDir</span><span class="p">)</span>
        <span class="c1"># 打包(windows为gradlew assembleRelease)</span>
        <span class="n">os</span><span class="o">.</span><span class="n">system</span><span class="p">(</span><span class="s2">&#34;gradle assembleRelease&#34;</span><span class="p">)</span>

<span class="c1"># 将代码及资源文件回归到原位</span>
<span class="n">replaceText</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;/Users/smartzheng/AndroidStudioProjects/MyApplication/app/src/main/java/com/smartzheng/Config.java&#39;</span><span class="p">,</span><span class="n">replaceText</span><span class="p">[</span><span class="nb">len</span><span class="p">(</span><span class="n">appNames</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span><span class="n">replaceText</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="n">replaceText</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;/Users/smartzheng/AndroidStudioProjects/MyApplication/app/src/main/res/values/strings.xml&#39;</span><span class="p">,</span> <span class="n">appNames</span><span class="p">[</span><span class="nb">len</span><span class="p">(</span><span class="n">appNames</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span><span class="n">appNames</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="n">replaceText</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;/Users/smartzheng/AndroidStudioProjects/MyApplication/app/build.gradle&#39;</span><span class="p">,</span><span class="n">apkNames</span><span class="p">[</span><span class="nb">len</span><span class="p">(</span><span class="n">appNames</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span><span class="n">apkNames</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="n">replaceText</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;/Users/smartzheng/AndroidStudioProjects/MyApplication/app/build.gradle&#39;</span><span class="p">,</span><span class="n">appIds</span><span class="p">[</span><span class="nb">len</span><span class="p">(</span><span class="n">appIds</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span><span class="n">appIds</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="n">copyFiles</span><span class="p">(</span><span class="n">sourceDir</span> <span class="o">+</span> <span class="n">replaceText</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">targetDir</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="s2">&#34;success&#34;</span><span class="p">)</span>

</code></pre></td></tr></table>
</div>
</div><h3 id="代码保存为autoreleasepy">代码保存为autoRelease.py</h3>
<h3 id="默认情况下gradle文件需要加入以下内容">默认情况下，.gradle文件需要加入以下内容：</h3>
<h3 id="android节点下">android节点下：</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">applicationVariants.all { variant -&gt; 
        variant.outputs.each { output -&gt;  
            //开始输出
            output.outputFile = new File(outputPathName)
        }
    }  
</code></pre></td></tr></table>
</div>
</div><h3 id="输出路径修改">输出路径修改</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">def apkName = &#34;apk1&#34;//apkNames[0]，每次输出不一样名字的apk
//前面加上自己的本地输出路径
def outputPathName = /Users/smartzheng/AndroidStudioProjects/apks + apkName
</code></pre></td></tr></table>
</div>
</div><h3 id="默认的applicationid">默认的applicationId</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">applicationId &#34;com.smartzheng.&#34; + applicationId1 //默认为前缀加appIds[0]
</code></pre></td></tr></table>
</div>
</div><p>只需在命令行中键入python autoRelease，即可运行打包，原来需要大半天搞定的工作，现在只需静待电脑自动完成即可。</p>
<p>另外，项目中需要替换的内容不多，如果多的话还可以利用字典进行优化。</p>
<h3 id="以上">以上。</h3>

    </div>

    <div class="post-copyright">
  <p class="copyright-item">
    <span class="item-title">文章作者</span>
    <span class="item-content">smartzheng</span>
  </p>
  <p class="copyright-item">
    <span class="item-title">上次更新</span>
    <span class="item-content">
        2018-03-28
        
    </span>
  </p>
  
  
</div>
<footer class="post-footer">
      
      <nav class="post-nav">
        <a class="prev" href="/post/android%E8%BF%9B%E7%A8%8B%E5%90%AF%E5%8A%A8%E6%B5%81%E7%A8%8B%E7%AE%80%E6%9E%90/">
            <i class="iconfont icon-left"></i>
            <span class="prev-text nav-default">Android进程启动流程简析</span>
            <span class="prev-text nav-mobile">上一篇</span>
          </a>
        <a class="next" href="/post/%E5%88%A9%E7%94%A8spannablestring%E5%AF%8C%E6%96%87%E6%9C%AC%E6%96%B9%E5%BC%8F%E8%AE%BE%E7%BD%AE%E5%9C%86%E8%A7%92%E6%A0%87%E7%AD%BE%E8%83%8C%E6%99%AF/">
            <span class="next-text nav-default">利用SpannableString富文本方式设置圆角标签背景</span>
            <span class="next-text nav-mobile">下一篇</span>
            <i class="iconfont icon-right"></i>
          </a>
      </nav>
    </footer>
  </article>
        </div>
        

  

  

      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="social-links">
      <a href="mailto:smartzheng1993@email.com" class="iconfont icon-email" title="email"></a>
      <a href="https://github.com/smartzheng" class="iconfont icon-github" title="github"></a>
      <a href="https://weibo.com/2062336885/profile?topnav=1&amp;wvr=6" class="iconfont icon-weibo" title="weibo"></a>
      <a href="https://www.zhihu.com/people/liu-xia-hui-89-70" class="iconfont icon-zhihu" title="zhihu"></a>
      <a href="https://www.douban.com/people/smartzheng/" class="iconfont icon-douban" title="douban"></a>
  <a href="https://smartzheng.github.io/index.xml" type="application/rss+xml" class="iconfont icon-rss" title="rss"></a>
</div>

<div class="copyright">
  <span class="power-by">
    由 <a class="hexo-link" href="https://gohugo.io">Hugo</a> 强力驱动
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    主题 - 
    <a class="theme-link" href="https://github.com/olOwOlo/hugo-theme-even">Even</a>
  </span>

  

  <span class="copyright-year">
    &copy; 
    2017 - 
    2020
    
  </span>
</div>
    </footer>

    <div class="back-to-top" id="back-to-top">
      <i class="iconfont icon-up"></i>
    </div>
  </div>
  
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/slideout@1.0.1/dist/slideout.min.js" integrity="sha256-t+zJ/g8/KXIJMjSVQdnibt4dlaDxc9zXr/9oNPeWqdg=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.js" integrity="sha256-XVLffZaxoWfGUEbdzuLi7pwaUJv1cecsQJQqGLe7axY=" crossorigin="anonymous"></script>
<script type="text/javascript" src="/dist/even.26188efa.min.js"></script>








</body>
</html>
